// pages/activity/resultDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    resultInfo: {

    }
  },


  onLoad(options) {
    // 根据id获取活动详情
    if (options.oid) {
      this.setData({
        oid: options.oid
      })
      this.getActivityDetail(options.oid)
    }
  },
  previewImage: function (e) {
    console.log('我被调用了')
    const current = e.currentTarget.dataset.url;
    const urls = [];

    // 收集所有存在的图片URL
    for (let i = 1; i <= 8; i++) {
      if (this.data.resultInfo[`image${i}`]) {
        urls.push(this.data.resultInfo[`image${i}`]);
      }
    }

    wx.previewImage({
      current: current, // 当前显示图片的链接
      urls: urls // 需要预览的图片链接列表
    });
  },
  getActivityDetail(id) {
    // TODO: 调用接口获取活动详情
    const app = getApp()
    app.activityApi.outcomesDetail(id).then(
      res => {
        this.setData({
          resultInfo: res.data.data
        })
        console.log(res.data)
      }
    )
  },
  onPullDownRefresh() {
    this.getActivityDetail(this.data.oid)
    setTimeout(() => {
      wx.stopPullDownRefresh()
      wx.showToast({
        title: '刷新成功',
        icon: 'success',
        duration: 1000
      })
    }, 1000)
  },


})